package com.bzchao.controller;

import com.bzchao.provider.OrderSender;
import com.bzchao.entity.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

@RestController
@RequestMapping("/")
public class MainController {
    @Autowired
    private OrderSender orderSender;

    // http://localhost:8082/msg?orderId=11&msg=abcd
    @RequestMapping("/msg")
    public void add(Long orderId, String msg) {
        String msgID = System.currentTimeMillis() + "$" + UUID.randomUUID().toString();
        Order order = new Order(orderId, msg, msgID);
        orderSender.sendOrder(order);
    }

}